//package com.easipass.business.controller.authentication;
//
//import com.easipass.business.constant.ActionConstants;
//import com.easipass.business.constant.BusinessCode;
//import com.easipass.business.dto.page.ResourcePageDTO;
//import com.easipass.business.dto.save.ResourceSaveDTO;
//import com.easipass.business.dto.vo.ResourceVO;
//import com.easipass.business.exception.BusinessException;
//import com.easipass.business.service.ResourceService;
//import com.easipass.commons.result.dto.RestMultiResult;
//import com.easipass.commons.result.dto.RestResult;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
//@RestController
//@RequestMapping("{version}/resources")
//@Slf4j
//public class ResourcesController {
//
//    @Autowired
//    ResourceService resourceService;
//
//    @GetMapping("{resourceName}")
//    public RestResult<ResourceVO> get(@PathVariable String resourceName){
//        return RestResult.T(resourceService.getResourceVOByResourceName(resourceName));
//    }
//
//    @DeleteMapping("{resourceName}")
//    public RestResult delete(@PathVariable String resourceName){
//        return RestResult.T(resourceService.deleteByResourceName(resourceName));
//    }
//
//    @PostMapping
//    public RestResult save(@RequestBody ResourceSaveDTO resourceSaveDTO){
//        return RestResult.T(resourceService.save(resourceSaveDTO));
//    }
//
//    @PostMapping("{resourceName}")
//    public RestResult action(
//            @PathVariable String resourceName,
//            @RequestParam(value = "action") String action ,
//            @RequestParam(value = "resourceStatus" , required = false) Integer resourceStatus){
//        if(ActionConstants.CHANGE_RESOURCE_STATUS.equals(action)){
//            return RestResult.T(resourceService.updateResourceStatus(resourceName , resourceStatus));
//        }else {
//            throw new BusinessException(BusinessCode.CODE_500003);
//        }
//    }
//
//    @PostMapping("page")
//    public RestMultiResult<ResourceVO> page(@RequestBody ResourcePageDTO resourcePageDTO){
//        int count = resourceService.count(resourcePageDTO);
//        List<ResourceVO> resourceVOList = null;
//        if(count > 0){
//            resourceVOList = resourceService.page(resourcePageDTO , count);
//        }
//        return RestMultiResult.T(resourceVOList , count);
//    }
//}
